package com.demo.controller;

import com.demo.common.ResponseResult;
import com.demo.domain.User;
import com.demo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.web.bind.annotation.*;

@RestController
//@RequestMapping("")
public class LoginController {
    @Autowired
    private LoginService loginService;


    /**
     * 登录
     * @param user
     * @return
     */
    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user){
        //返回值类型是ResponseResult
        return loginService.login(user);
    }

    /**
     * 退出登录
     * @return
     */
    @GetMapping("/user/logout")
    public ResponseResult logout(){
        return loginService.logout();
    }
}
